
<template>
     <el-date-picker
      :style="styles"
      v-model="currentValue"
      :id="id"
      type="month"
      :editable="false"
      value-format="yyyy-MM"
      :class="classs"
      placeholder="选择日期">
    </el-date-picker>

   
    
</template>
 
<script>
    export default {
        props:['id','styles','value','data','index','isBorder','isSearch','exkey'],
        name: "input-date-month",
        data(){
            return {
                currentValue:this.value,
                classs:'',
                pId:"",
                cId:"",
                paramKey:""
            }
        },
        created(){
            if(this.isBorder=='N')
                this.classs="no-border";
            
            if(this.isSearch!='Y'){
                if(!this.value){
                    let ids=this.id.split(".");
                    if(ids.length>1){
                        let p=ids[0];
                        let id_=ids[1];
                        this.pId=p;
                        this.cId=id_;
                        if(this.index||this.index=='0'){
                            try{
                                this.currentValue=unescape(this.data[p][this.index][id_]);
                            }catch(e){}
                        }else{
                            try{
                                this.currentValue=unescape(this.data[p][id_]);
                            }catch(e){}
                        }
                    }else{
                        this.currentValue=unescape(this.data[this.id]);
                    }
                    if(!this.style){
                        this.style="width:180px"
                    }
                }else{
                    
                    let data={};
                    data.id=this.id;
                    data.val=this.value;
                    data.index=this.index;
                    this.$emit('input',JSON.stringify(data));
                }
            }else{
                this.currentValue=unescape(this.data[this.index].vals)
            }
           
            try{
                this.paramKey=this.exkey.paramKey;
            }catch(e){}
            
        },
        watch:{
            currentValue: function (val) { //currentValue值变动就向父组件传值
                if(!val){
                    val="";
                }
               
                if(this.isSearch!='Y'){
                    let data={};
                    data.id=this.id;
                    data.val=val;
                    data.index=this.index;
                    
                    if(this.pId){
                        if(this.index!=""&&(this.index==0||this.index>0)){
                            let data_=this.data[this.pId][this.index];
                            data_[this.cId]=val;
                            this.$set(this.data[this.pId],this.index,data_)
                        }else
                            this.$set(this.data[this.pId],this.cId,val)
                    }else{
                        this.$set(this.data,this.id,val)
                    }
                }else{
                    //可能搜索用到
                    this.$set(this.data[this.index],"vals",val);
                }
                console.log(this.paramKey,"this.paramKeys==========sss===")
                if(this.paramKey){
                    let params={};
                    params.paramKey=this.paramKey;
                    params.params=this.currentValue;
                    params.id=this.id;
                    this.$parent.$parent.$parent.$parent.$parent.$parent.loadDataParam(params)
                }
                //this.$emit('input',JSON.stringify(data));
               // this.$emit('on-change',JSON.stringify(data));
            },
            value:function (val) { //对值进行验证0
                
            }
        }
    }
</script>
<style scoped>
.formitem{
    margin-left:35px;
}
.formitem2{
    margin-left:10px;
}
</style>